<?php
//error_reporting(0);
class DbUtils extends AbstractDbUtils
{
	
	public static function Connection(){

        if(empty($_REQUEST[CONNECTION_KEY])){
            $_REQUEST[CONNECTION_KEY]  =new pdo_db("s1.wfserver.com.cn,40033","runxun","runxundev","RunXun");
        }
        return $_REQUEST[CONNECTION_KEY];
		
	}
	
	
	public static function pdo_connection($key=CONNECTION_KEY,$transaction=false ){
	    if(empty($_REQUEST[$key])){
	    	$conn = new pdo_db("s1.wfserver.com.cn,40033","runxun","runxundev","RunXun");
            if($transaction== true){
            	$conn->beginTransaction();
            }
            $_REQUEST[$key] = $conn;
        }
        return $_REQUEST[$key];
	}


	public static function GetOpenedConnection($key =CONNECTION_KEY,$createNew=false){
	    $conn = null;
	    if(!empty($_REQUEST[$key])){
            $conn = $_REQUEST[$key] ;
        }
        if($conn == null && $createNew == true){
        	$conn =  DbUtils::pdo_connection($key);
        }
        return $conn;
	}

    public  function get_pdo_connection($key=CONNECTION_KEY,$transaction=false ){
        /*if(empty($_REQUEST[$key])){
            $conn = new pdo_db("localhost","sa","123456","RunXun");
            if($transaction== true){
                $conn->beginTransaction();
            }
            $_REQUEST[$key] = $conn;
        }
        return $_REQUEST[$key];*/
        return new pdo_db("s1.wfserver.com.cn,40033","runxun","runxundev","RunXun");
    }


    public  function get_opened_connection($key =CONNECTION_KEY,$createNew=false){
        $conn = null;
        if(!empty($_REQUEST[$key])){
            $conn = $_REQUEST[$key] ;
        }
        if($conn == null && $createNew == true){
            $conn =  DbUtils::pdo_connection($key);
        }
        return $conn;
    }




	
}
